package medium

import "strings"

func simplifyPath(path string) string {

	stack := make([]string, 0)
	split := strings.Split(path, "/")

	for i := 0; i < len(split); i++ {
		switch split[i] {
		case "", ".":
		case "..":
			if len(stack) > 0 {
				stack = stack[:len(stack)-1]
			}
		default:
			stack = append(stack, split[i])
		}
	}

	return "/" + strings.Join(stack, "/")
}
